package com.atguigu.DAO.impl;

import com.atguigu.pojo.User;
import org.springframework.stereotype.Repository;

@Repository
public class UserDaoImple extends BaseDAO implements UserDAO{

    @Override
    public User queryUserByUsername(String username) {
        String sql="select id,username,`password`,email from t_user where username=?";

        return queryForOne(User.class,sql,username);
    }

    @Override
    public User queryUserByUsernameandpassword(String username, String password) {
       String sql="select id,username,`password`,email from t_user where username=? and password=?";
       return queryForOne(User.class,sql,username,password);
    }

    @Override
    public int saveUser(User user) {
       String sql="insert t_user(id,username,`password`,email) values(?,?,?,?)";
       return update(sql,user.getId(),user.getUsername(),user.getPassword(),user.getEmail());
    }
}
